package org.duang.common.exceptios;

import org.duang.common.enums.IEnums;

/**
 * Service层公用的Exception.
 * 
 */
public class ServiceException extends RuntimeException {

	
	private static final long serialVersionUID = 1401593546385403720L;

	private int code = IEnums.IENUMS_FAIL_CODE;
	private String message = IEnums.IENUMS_FAIL_MESSAGE;
	private IEnums enums;
	
	public ServiceException() {
		super();
	}
	
	public ServiceException(String message) {		
		super(message);
		this.setMessage(message);
	}	

	public ServiceException(Throwable cause) {
		super(cause);
	}

	public ServiceException(String message, Throwable cause) {
		super(message, cause);
		this.setMessage(message);
	}
	
	public ServiceException setCode(int code) {
		this.code = code;
		return this;
	}
	
	public ServiceException setMessage(String message) {
		this.message = message;
		return this;
	}
	
	public ServiceException setIEnums(IEnums enums) {
		this.enums = enums;
		return this;
	}
	
	public ServiceException(IEnums enums) {
//		super(enums.getMessage());
		this.message = enums.getMessage();
		this.enums = enums;
	}

	public int getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}

	public IEnums getEnums() {
		return enums;
	}	
}
